/*
 * @Author: 张书源 526384196@qq.com
 * @Date: 2023-11-19 08:55:43
 * @LastEditors: 张书源 526384196@qq.com
 * @LastEditTime: 2023-11-19 08:58:16
 * @FilePath: \blog-admin\vite.config.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

const resolve = (dir)=>path.resolve(__dirname,'.',dir);

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': resolve('src')
    },
  },
  base: '/', // 设置打包路径
  server: {
    port: 5174, // 服务器启动端口
    open: true, // 服务器启动时是否自动打开浏览器
    cors: true, // 允许跨域
    // 设置代理
    proxy: {
      '/api': {
        target: 'http://60.204.149.38:9001',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      }
    }
  },
})